#include<stdio.h>
#include<unistd.h>
#include <stdlib.h>
int main()
{
    pid_t id = fork();
    if(id < 0)
    {
        //fork 失败 打印失败原因
        perror("fork");
        return 1;
    }
    else if(id == 0)
    {
        //child
        while(1)
        {
            printf("I am child pid::%d ppid::%d\n",getpid(), getppid());
            sleep(3);
            break;

        }
        exit(-1);
    }
    else 
    {
        //parent
        while(1)
        {
            printf("I am father pid::%d ppid::%d\n",getpid(), getppid());
            sleep(1);
        }
    }

    
    return 0;
}
